package com.course.design.handler;

import com.course.design.common.Result;
import com.course.design.exception.ExecuteException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * 描述:
 *
 * @author qinlianji
 * @create 2020-03-22
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = ExecuteException.class)
    public Result domainExceptionHandler(HttpServletRequest req, ExecuteException e) throws Exception {
        e.printStackTrace();
        Result result = Result.result(e.getErrCode(), e.getMessage(), null);
        return result;
    }
}
